#include "Client.h"
#include "..\Server\Server.h"

int main()
{
	Client c;
	Server s;
	s.start();	
	c.river()->connect("127.0.0.1", 9998);
	s.river(c.river());
	c.threadobject(c.river(), &c, &s);
	c.start();
	for (int i = 0; i < 1; i++)
	{
		packet * p = new packet();
		LoginPacket * lp;
		p->Header.state = REQUEST;
		memset(p->msg, 0, sizeof(LoginPacket));
		lp = c.river()->login(104566, "COLD1");
		memcpy(p->msg, lp, sizeof(LoginPacket));
		p->Header.Type = LOGIN;
		c.push(p);
		c.river()->TRACE(2, "Sent login request\n");
		for (int i = 0; i < 5; i++)
		{
			if (c.river()->loggedin())
			{
				i = 5;
				c.river()->TRACE(2, "Logged in\n");
			}
			else
			{
				c.river()->TRACE(2, "Waiting for login request\n");
				Sleep(1000);
			}
		}
	}
	char message[1024];
	Sleep(20000);
	sprintf(message, "Got %d responses\n", s.response());
	s.river()->TRACE(10,message);
	Sleep(INFINITE);
}